package com.help10000.rms.ui.activitys

import android.content.Intent
import android.os.Bundle
import android.util.Log
import com.amir.common.beans.BaseResult
import com.amir.common.utils.HideUtil
import com.amir.common.utils.ToastUtil
import com.amir.common.weight.DuplicateClickProxy
import com.help10000.rms.R
import com.help10000.rms.mvp.presenter.ApplyEntryPresenter
import com.help10000.rms.mvp.view.CommonView
import com.help10000.rms.ui.base.BaseActivity
import kotlinx.android.synthetic.main.activity_apply_entry.*
import kotlinx.android.synthetic.main.activity_forget_pwd.*
import kotlinx.android.synthetic.main.activity_navigation.*


/**
 * 申请入职
 */
class ApplyEntryActivity : BaseActivity<ApplyEntryPresenter, CommonView<BaseResult>>(),
    CommonView<BaseResult> {

    override fun getlayoutId(): Int {
        return R.layout.activity_apply_entry
    }

    override fun createPresenter(): ApplyEntryPresenter {
        return ApplyEntryPresenter(this)
    }

    override fun initView() {
        btn_next.setOnClickListener(DuplicateClickProxy{
            if (edit_code.text.toString().isEmpty()) {
                Log.v("isFastDoubleClick", "请输入公司代码")
                ToastUtil.show("请输入公司代码")
                return@DuplicateClickProxy
            }
            mPresenter?.applyInit(edit_code.text.toString())
        })
    }

    override fun initData(savedInstanceState: Bundle?) {
        edit_code.requestFocus()

        HideUtil.openKeyboard(mContext, edit_code)

    }


    override fun onDataSuccess(data: BaseResult) {
        var intent = Intent(this, ApplyWorkActivity::class.java)
        intent.putExtra("cmpycode", edit_code.text.toString())
        startActivity(intent)
        finish()
    }
}